<?php

namespace app\adminapi\validate;

use app\common\validate\BaseValidate;

class SysUserValidate extends BaseValidate
{
    protected $rule = [
        'pageNo' => 'regex:/^([1-9]\d*)$/',
        'pageSize' => ['regex'=>'/^(-1|[1-9]\d*)$/'],
        'timeArr' => 'array',
        'userId' => 'require|number',
        'userName' => 'require',
        'nickName' => 'require',
        'password' => 'require',
        'phonenumber' => 'require',
        'roleId' => 'require|number',
        'status' => 'require|number|in:0,1'
    ];

    protected $message = [
        'pageNo.regex' => '分页页码只能是数字',
        'pageSize.regex' => '分页页大小只能是数字',
        'timeArr.array' => '时间数组格式错误',
        'userId.require' => '用户参数不完整',
        'userId.number' => '用户ID类型错误',
        'userName.require' => '请输入用户账号',
        'nickName.require' => '请输入用户昵称',
        'password.require' => '请输入登录密码',
        'phonenumber.require' => '请输入手机号码',
        'roleId.require' => '请选择角色',
        'roleId.number' => '角色参数错误',
        'status.require' => '请输入用户状态',
        'status.number' => '用户状态必须为数字',
        'status.in' => '用户状态参数不合法'
    ];

    protected $scene = [
        'list' => ['pageNo', 'pageSize', 'timeArr'],
        'insert' => ['userName', 'nickName', 'password', 'phonenumber', 'roleId'],
        'delete' => ['userId'],
        'query' => ['userId'],
        'update' => ['userId', 'userName', 'nickName', 'phonenumber', 'roleId'],
        'changeStatus' => ['userId', 'status'],
        'resetPwd' => ['userId', 'resetPwd']
    ];
}